define(function() {
    'use strict';
    class List{
        constructor(){
            this.cont = $("#cont");
            this.url = "data/pro.json";

            this.load();
        }
        load(){
            $.ajax({
                url:this.url,
                success:(res)=>{
                    this.res = JSON.parse(res);
                    this.render();
                }
            })
        }
        render(){
            let str = "";
            for(let i=0;i<this.res.length;i++){
                str += `<div class="box" data-id="${this.res[i].goodsId}"><a href="detail.html?id=${this.res[i].goodsId}">
                            <img src="${this.res[i].img[0].small}">
                            <p>${this.res[i].price}</p>
                            <p>${this.res[i].name}</p></a>
                            <span>加入购物车</span>
                        </div>`
            }
            this.cont.html(str);
        }
    }
    return List;
});